﻿@{
    ViewBag.Title = "GiveAuthorization";
    Layout = "~/Areas/Admin/Views/Shared/_LayoutCMS.cshtml";
}

@section htmlhead{
    <link href="~/Content/assets/css/Layout/css/main.css" rel="stylesheet" />
    <link href="~/Content/assets/css/plugin/validator.css" rel="stylesheet" />
    <link href="~/Content/assets/css/ztree/zTreeStyle.css" rel="stylesheet" />
}

@model LY.Entity.S_Role
<div class="container">
    <div id="forms" class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">权限管理</b></div>
                <div class="box_center">
                    <form  id="frmEdit" method="post" action="@Url.Action("SaveAuthorization")" role="form" class="jqtransform">
                        <input id="hideId" name="ID" value="@Model.ID" type="hidden" />
                        <table class="form_table pt15 pb15" style="width: 100%;" border="0">
                            <tr>
                                <td class="td_right">角色：</td>
                                <td class="">@Model.Name</td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <label for="checkAll">全选</label>
                                    <input type="checkbox" value="全选" name="checkAll" id="checkAll" />
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">权限：</td>
                                <td class="">
                                    <div id="gridlist">
                                        @{
                                            var MList = ViewBag.MList;
                                            var blankstr = "　　";
                                            for (int i = 0; i < MList.Count; i++)
                                            {

                                                if (MList[i].Layer == 2)
                                                {
                                            @Html.Raw(" <div class=\"label" + MList[i].ParentID + "\">")
                                                }
                                                for (int b = 1; b < MList[i].Layer; b++)
                                                {
                                            @blankstr 
                                                }
                                                if (MList[i].UserRoleID == 0)
                                                {
                                            <input  name="nodesID" type="checkbox" value="@MList[i].ID"> @MList[i].Name<br />
                                                }
                                                else
                                                {
                                            <input name="nodesID" type="checkbox"  value="@MList[i].ID" checked="checked"> @MList[i].Name<br />
                                                }
                                                if (MList[i].Layer == 2)
                                                {
                                            @Html.Raw(" </div>")
                                                }

                                            }
                                        }
                                    </div>
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right"></td>
                                <td class=""></td>
                            </tr>
                            <tr>
                                <td class="td_center" colspan="5">
                                    <input type="button" id="btnSave" name="button" style="margin-right: 50px;" class="btn btn82 btn_save2" value="保存">
                                    <input type="button" id="btnReturn" name="button" class="btn btn82 btn_res" value="返回">
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@section jssection{
    <script type="text/javascript">
        var util = {};
        var options = {
            listUrl: "@Url.Action("SetRoleModuleList")"
            @*,
            editUrl: "@Url.Action("MemberEdit")",
            deleteUrl: "@Url.Action("MemberDelete")",
            AuthenticateUrl: "@Url.Action("PwdEdit")",
            CertifiedmailUrl: "@Url.Action("SendMail")",
            assignUrl: "@Url.Action("DeptAssignPop")"*@

        };

        //x选择下级
        $("#gridlist input[type='checkbox']").each(function () {
            $(this).click(function () {
                var parentid = this.value;
                if (this.checked) {
                    $(".label" + parentid + " input[type='checkbox']").each(function () {
                        $(this).prop("checked", true);
                    });
                } else {
                    $(".label" + parentid + " input[type='checkbox']").each(function () {
                        $(this).prop("checked", false);
                    });
                }
            });
        });
        //全选 
        $("#checkAll").click(function () {
            if (this.checked) {
                $("#gridlist input[type='checkbox']").each(function () {
                    $(this).prop("checked", true);
                });
            } else {
                $("#gridlist input[type='checkbox']").each(function () {
                    $(this).prop("checked", false);
                });
            }
        });

    </script>
    <script src="~/Content/assets/plugins/validator/validator.js"></script>
    <script src="~/Content/assets/app/role/setrolemodule.js"></script>
    <script src="~/Content/assets/plugins/validator/validator.js"></script>
    <script src="~/Content/assets/app/role/setrolemodule.js"></script>
}